<%@ page import="com.struts.pojo.Student"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Taglib</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
  </head>
  
  <body>
  
  		<h3>if标签：判断分支</h3>
  		<%
  		 	int length=15;  
  	    	request.setAttribute("len",length); 	
  		%>
  		<s:if test="#request['len'] > 20">
  			您输入的值大于20 ；<br>
  		</s:if>
  		<s:elseif test="#request['len'] < 10">
  			您输入的值小于10 ；<br>
  		</s:elseif>
  		<s:else>
  			您输入的值在10-20之间；<br>
  		</s:else>
		<hr>
		<h3>iterator标签：迭代输出值栈中的元素</h3>
		<s:iterator var="i" begin="1" step="1" end="10">
<%--			<s:debug></s:debug>--%>
			<s:property value="#i"/>
		</s:iterator><br><br>
		<%
			List<Student> list = new ArrayList<Student>() ;
			
			Student stu01 = new Student("张三01",21) ;
			Student stu02 = new Student("张三02",22) ;
			Student stu03 = new Student("张三01",21) ;
			Student stu04 = new Student("张三04",24) ;
			
			list.add(stu01) ;
			list.add(stu02) ;
			list.add(stu03) ;
			list.add(stu04) ;
			
			request.setAttribute("list", list) ;
		%>
		<table border="1">
			<tr>
				<th colspan="4" align="center">list集合</th>
			</tr>
			<tr>
				<th>索引</th>
				<th>姓名</th>
				<th>性别</th>
				<th>操作</th>
			</tr>
			<s:iterator status="state" value="#request['list']" var="list">
				<tr
					<s:if test="#state.even">
						bgcolor="#EFF8FF"
					</s:if>
					<s:else>
						bgolor="#B4CFF1"
					</s:else>
				>
				<td><s:property value="#state.index"/></td>
				<td><s:property value="#list.name"/></td>
				<td><s:property value="#list.age"/></td>
				<td><a href="">修改</a>	<a href="">删除</a></td>
			</s:iterator>
		</table><br><br>
		<%
			Set<Student> set = new HashSet<Student>() ;
			set.add(stu01) ;
			set.add(stu02) ;
			set.add(stu03) ;
			set.add(stu04) ;
			request.setAttribute("set", set) ;
		%>
		<table border="1">
			<tr>
				<th colspan="4" align="center">set集合</th>
			</tr>
			<tr>
				<th>索引</th>
				<th>姓名</th>
				<th>性别</th>
				<th>操作</th>
			</tr>
			<s:iterator status="state" value="#request['set']">
				<tr
					<s:if test="#state.even">
						bgcolor="#EFF8FF"
					</s:if>
					<s:else>
						bgolor="#B4CFF1"
					</s:else>
				>
				<td><s:property value="#state.index"/></td>
				<td><s:property value="name"/></td>
				<td><s:property value="age"/></td>
				<td><a href="">修改</a>	<a href="">删除</a></td>
			</s:iterator>
		</table><br><br>
		<%
			Map<String,Student> map = new HashMap<String,Student>() ;
			map.put("stu01",stu01) ;
			map.put("stu02",stu02) ;
			map.put("stu03",stu03) ;
			map.put("stu04",stu04) ;
			request.setAttribute("map", map) ;
		%>
		<table border="1">
			<tr>
				<th colspan="4" align="center">map集合</th>
			</tr>
			<tr>
				<th>索引</th>
				<th>姓名</th>
				<th>性别</th>
				<th>操作</th>
			</tr>
			<s:iterator status="state" value="#request['map']">
<%--				<s:debug></s:debug>--%>
				<tr
					<s:if test="#state.even">
						bgcolor="#EFF8FF"
					</s:if>
					<s:else>
						bgolor="#B4CFF1"
					</s:else>
				>
				<td><s:property value="#state.index"/></td>
				<td><s:property value="value.name"/></td>
				<td><s:property value="value.age"/></td>
				<td><a href="">修改</a>	<a href="">删除</a></td>
			</s:iterator>
		</table><br><br>
  </body>
</html>
